const tokenKey = 'token'
const domainKey = 'domain'
const userNamesKey = 'userNames'
const rolesKey = 'roles'
const usernameKey = 'username'
const loginlogidKey = "loginlogid"
const usercodeKey = "usercode"

export function getLoginlogid() {
    return localStorage.getItem(loginlogidKey)
}

export function setLoginlogid(loginlogid) {
    return localStorage.setItem(loginlogidKey, loginlogid)
}

export function removeLoginlogid() {
    return localStorage.removeItem(loginlogidKey)
}

export function getToken() {
    return localStorage.getItem(tokenKey)
}

export function setToken(token) {
    return localStorage.setItem(tokenKey, token)
}

export function removeToken() {
    return localStorage.removeItem(tokenKey)
}

export function getDomain() {
    return localStorage.getItem(domainKey) || process.env.VUE_APP_BASE_API
}

export function setDomain(domain) {
    return localStorage.setItem(domainKey, domain)
}

export function getUserNames() {
    return localStorage.getItem(userNamesKey)
}

export function setUserNames(usernames) {
    return localStorage.setItem(userNamesKey, usernames)
}

export function getRoles() {
    const roles = localStorage.getItem(rolesKey) || '[]'
    return JSON.parse(roles)
}

export function setRoles(roles) {
    return localStorage.setItem(rolesKey, JSON.stringify(roles.pages))
}

export function removeRoles() {
    return localStorage.removeItem(rolesKey)
}

export function getUsername() {
    return localStorage.getItem(usernameKey)
}

export function setUsername(username) {
    return localStorage.setItem(usernameKey, username)
}

export function getUsercode() {
    return localStorage.getItem(usercodeKey)
}

export function setUsercode(usercode) {
    return localStorage.setItem(usercodeKey, usercode)
}

export function removeUsername() {
    return localStorage.removeItem(usernameKey)
}